﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XMK.Tadong.Biz;
using XMK.Tadong.Model.Cond;
using XMK.Framework.Model;

namespace XMK.Tadong.Web.Handlers
{
    /// <summary>
    /// FileRightsCheck 的摘要说明
    /// </summary>
    public class FileRightsCheck : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string targetid = (HttpContext.Current.Request["targetid"] ?? "").Trim();
            if (targetid != "") {
                Base_RM_UserInfoBiz userBiz = new Base_RM_UserInfoBiz();
                ResponseInfo response=userBiz.QueryRoleTreeRights();
                if (response != null)
                {
                    List<FileRightsInfo> list = (List<FileRightsInfo>)response.Data;
                    List<FileRightsInfo> curlist = list.Where((FileRightsInfo f) => { return f.ObjID == targetid; }).ToList() ;
                    if (curlist.Count > 0)
                    {
                        int FileLevel = curlist[0].RightsLevel;
                        //跳转到对应路径
                        string url = "";
                        HttpContext.Current.Response.Redirect(url);
                    }
                    else
                    { 
                        //没有权限访问
                        string errurl = "";
                        HttpContext.Current.Response.Redirect(errurl);
                    }
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}